GTK FORM Objects
HotBasic Linux provides two modes for $APPTYPE GUI: GTK-mode (present default) and X11-mode, invoked by use of the compiler -X switch or $X11 directive. bob $APPTYPE GUI in GTK-Mode uses libgtk-x11-2.0.so.0 and libgobject-2.0.so.0 directly. Several downloads such as hbgtkgui.zip show source code examples. As GTK-Mode further develops more demo downloads showing new features will be added, and may provide the best tool to see working code syntax to construct your own applications. Users like AIR have demos showing alternate routes toward application writing. E.g., glade's form designer may be used to produce an .xml file which can be tranlated into HotBasic code. AIR's demos also show numerous techniques, such as creating menus and manipulating fonts, which are not yet native. Indeed, this is "normal". Creative users marched ahead of HotBasic development in the Windows version GUI apps and the same can be expected for Linux, too. Form Objects * FORM (Unlike Windows, FORM .Height and .ClientHeight are equal and .Width and .ClientWidth are equal.) * BUTTON * CANVAS * CHECKBOX * COMBOBOX * DATETIME * EDIT * FILELISTBOX (Alias for LISTBOX) * GAUGE * GRID * GROUPBOX * HEADER * IMAGE * LABEL * LISTBOX * LISTVIEW * PANEL * RADIOBUTTON * RICHEDIT * RICHEDIT2 (Unlike Windows, alias for RICHEDIT) * SCROLLBAR * SPLASH * STATUSBAR * TABCONTROL * TOOLBAR * TRACKBAR * TREEVIEW * UPDOWN (In X11-mode, scrolls text list; in GTK-mode, behaves as a GtkAdjustment) PROPERTIES PROPERTIES Comments (RW numeric or string values) * Caption Set/get object text; same as .Text only: COMBOBOX * Checked Set/get checked state CHECKBOX RADIOBUTTON * Class Class name string. MyClass = MyObject.Class * Color Set/get background color by RGB value 0 - &HFFFFFF * Enabled Enables user input with mouse or keyboard to object * Font Set font for object text. MyObject.Font = MyFont * Height Set/get object height. If set for IMAGE, IMAGE may be resized. * ItemIndex Set/get selected item. LISTBOX only: COMBOBOX * Left Set/get object left position * Parent Set/get handle of .Parent to object. MyObject.Parent = MyObject * Position Set/get position SCROLLBAR TRACKBAR UPDOWN * Style Set/get Style. For FORM, default = &HCF0000 * Tag Set/get arbitrary value associated with object. MyEdit.Tag = 12 * Text Set/get object text; same as .Caption. * TextColor Set/get RGB color of text. * Top Set/get object top position * Visible Displays or hides object (default = true) * Width Set/get object width. PROPERTIES (Read Only String) * Item Item text LISTBOX PROPERTIES (Read Only Numeric) * ClientHeight Same as .Height; client area height. cHeight = MyForm.ClientHeight * ClientWidth Same as .Width; client area width. cWidth = MyForm.ClientWidth * Handle Object handle * ID Object ID assigned internally at object creation * Length Length of object text (if referenced without an index) * MouseX Mouse x position in object rectangle; MyLong = MyForm.MouseX * MouseY Mouse y position in object rectangle; MyLong = MyForm.MouseY METHODS METHODS Arguments & Comments * AddItems Adds string(s). LISTBOX * Background Sets FORM color * Center Centers FORM on screen. MyForm.Center * Close Closes FORM. See OnClose event. * Destroy Destroys window object (alias for .Close) * Focus Sets focus to object. MyObject.Focus * ForeColor Sets GAUGE foreground (bar) RGB color. Please see .Color. * Foreground Sets FORM as foreground window. MyForm.Foreground * LoadFromFile * Recreate Destroys and creates object again. MyObject.Recreate * Resizeable Enables/disables FORM object resize. default = true * SaveToFile Saves file with object data. * Show Displays FORM or form object and its child components. * ShowModal Displays FORM and its child components. Program continues on close EVENTS 1. OnMessage now works! For any FORM object, OnMessage appears to be triggered for *all* the Gdk events, although this might require some confirmation. Thus, developers can use OnMessage (a) to have access to low-level events not serviced by other native event identifiers, and (b) to explore what events are available. These virtues of OnMessage are similar to those enjoyed by Windows OnMessage users. The prototype provided by GTK is arg1=widget handle and arg2 = pointer to a GdkEvent structure (please see my upload to FILES, users/jim, of gdktypes.inc for this). AIR recently posted use of a STD function declare for an event routine which works; however, one can get these arguments with stack(2) and stack(3), I think (because stack(1) is a saved register value). Anyway, arg1 should equal the widget handle, so a coder can confirm this equality and thus the next stack() item is the GdkEvent pointer, which can be used use evt as GdkEvent with stack(3) 'code end use evt 2. I did a (tiresome) survey for GTK-mode events. These are my results: GTK-Mode Events * OnClick CHECKBOX RADIOBUTTON * OnClose all * OnDblClick ??? * OnKeyDown CHECKBOX EDIT FORM LISTBOX LISTVIEW RADIOBUTTON RICHEDIT TABCONTROL TRACKBAR TREEVIEW UPDOWN* * OnKeyUp CHECKBOX EDIT FORM LISTBOX LISTVIEW RADIOBUTTON RICHEDIT TABCONTROL TRACKBAR TREEVIEW UPDOWN* * OnMessage provides all GdkEvents -- pointer at STACK(3) * OnMouseDown CANVAS CHECKBOX EDIT FORM GAUGE LISTBOX RADIOBUTTON RICHEDIT SCROLLBAR TRACKBAR UPDOWN* * OnMouseUp CANVAS CHECKBOX EDIT FORM GAUGE LISTBOX RADIOBUTTON RICHEDIT SCROLLBAR TRACKBAR UPDOWN* * OnMouseMove CANVAS CHECKBOX FORM GAUGE LISTBOX RADIOBUTTON SCROLLBAR TRACKBAR UPDOWN* Note: "*" EDIT RICHEDIT: only on enter and/or leave * OnPaint all * OnResize all * OnShow FORM Note: These event routines require RETVAL ZERO before END SUB or RETURN to ensure that GTK will run default processing code. Since RETVAL ZERO is not needed in Windows (except for OnMessage) or in Linux X11-mode, one can just insert it if the code will be compiled in GTK-mode or $DEFINE GTK and $IFDEF GTK: RETVAL ZERO: $ENDIF Where the GTK register nanny code is needed, one can just insert it for all platforms and modes, or use a similar $IFDEF GTK block.